<?php
// +----------------------------------------------------------------------
// | 中犇单商户
// +----------------------------------------------------------------------
// | Copyright (c) 2019-2021 中犇科技 All rights reserved.
// +----------------------------------------------------------------------


namespace app\admin\validate;

use think\Validate;

/**
 * 上传分类验证器
 * Class UploadCategory
 * @package app\admin\validate
 */
class UploadCategory extends Validate
{
    //定义验证规则
    protected $rule = [
        'id|ID'  => 'require',
        'name|分类名称'  => 'require|unique:upload_category|length:1,30',
    ];

    //定义验证提示
    protected $message = [
        'id.require' => '请填写ID',
        'name.require' => '请填写分类名称',
        'name.unique' => '该分类名称已存在',
        'name.length' => '分类名称长度1-30位',
    ];
    //定义验证场景
    protected $scene = [
        //更新
        'save'  =>  ['name'],
        //删除
        'delete'  =>  ['id'],
    ];
}
